package com.uenpay.im.ui.old.activity.movement;

import com.uenpay.im.configuration.APIConfiguration;
import com.uenpay.im.entities.HttpInvokeResult;
import com.uenpay.im.invokeitems.BaseHttpInvokeItem;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

public class CloseOrOpenMovementInvokeItem extends BaseHttpInvokeItem {
	public class CloseOrOpenMovementInvokeItemResult extends HttpInvokeResult {
		ArrayList<MovementEntity> arrayList = new ArrayList<MovementEntity>();
	}

	public CloseOrOpenMovementInvokeItemResult getOutput() {
		return (CloseOrOpenMovementInvokeItemResult) GetResultObject();
	}

	public CloseOrOpenMovementInvokeItem(int activityid, int status) {
		// http://api.aitiapp.com/Activity/switchActivity?activityid=
		String url = APIConfiguration.getBaseUrl()
				+ "Activity/Activity/switchActivity?activityid=" + activityid
				+ "&status=" + status + "&"
				+ APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) {
		CloseOrOpenMovementInvokeItemResult result = new CloseOrOpenMovementInvokeItemResult();
		JSONObject json = null;
		try {
			json = new JSONObject(responseBody);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		if (json == null) {
			return null;
		}
		result.status = json.optInt("status");
		result.msg = json.optString("msg");
		if (result.status != 0) {
			return result;
		}

		return result;
	}


}
